/*
 * Singularity Engine
 * Copyright (C) 2010 Vyacheslav Vorobyov, All rights reserved.
 * See LICENSE for full license information.
 */

/**
 * 
 */
package org.singularity.mapred.util;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;

import org.singularity.io.DME;

/**
 * @author vjache
 *
 */
public class ListVDME<T> extends WraperVDME<T, List<T>> implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2433735066183997114L;
	
	private final int _keyPos;
	
	private HashMap<Object, Object> _annots;

	public ListVDME(DME<List<T>> aDme, int aKeyPos)
	{
		super(aDme);
		_keyPos = aKeyPos;
	}
	@Override
	public T getKey() {
		return _dme.getValue().get(_keyPos);
	}
	@Override
	public Object getAnnotation(Object aKey) {
		if(_annots==null)
			return null;
		return _annots.get(aKey);
	}
	@Override
	public void putAnnotation(Object aKey, Object aValue) {
		if(_annots==null)
			_annots = new HashMap<Object, Object>(1);
		_annots.put(aKey, aValue);
	}
}
